package com.wenyl.threads.volatileTest;

/**
 * @author Swimming Dragon
 * @description: volatile可见性测试
 * @date 2024年11月01日 14:57
 */
public class VolatileSingleton {
    private volatile static VolatileSingleton singleton;
    public VolatileSingleton(){

    }
    public static VolatileSingleton getSingleton(){
        if(singleton == null){
            synchronized (VolatileSingleton.class){
                if(singleton == null){
                    singleton = new VolatileSingleton();
                }
            }
        }
        return singleton;
    }
}
